package com.itheima.list;

import java.util.*;

/**
 * List 练习
 */
public class Test01 {

    public static void main(String[] args) {
        //创建集合
        List<String> strs=new ArrayList<>();
        //添加元素
        strs.add("鹿晗");
        strs.add("关晓彤");
        strs.add("蔡徐坤");
        strs.add("蔡徐坤");
        strs.add("鹿晗");
        strs.add("吴亦凡");
        strs.add("鹿晗");

        //迭代器遍历
        Iterator<String> iterator = strs.iterator();
        System.out.println(iterator.next());
        System.out.println(iterator.next());
        System.out.println(iterator.next());
        System.out.println(iterator.next());
        System.out.println(iterator.next());
        System.out.println(iterator.next());
        System.out.println(iterator.next());
        //增强for
        System.out.println("------------------");
        //普通for


        Set<String> set= new TreeSet<>();
        set.add("鹿晗");
        set.add("关晓彤");
        set.add("蔡徐坤");
        set.add("蔡徐坤");
        set.add("鹿晗");
        set.add("吴亦凡");
        set.add("鹿晗");
        Iterator<String> iterator2 = set.iterator();
        System.out.println(iterator2.next());
        System.out.println(iterator2.next());
        System.out.println(iterator2.next());
        System.out.println(iterator2.next());

    }
}
